home *** CD-ROM | disk | FTP | other *** search
/ Netware Super Library / Netware Super Library.iso / chatmail / isfile / isfile.c next >
Text File  |  1990-09-30  |  690b  |  34 lines

  1. /*
  2.  * ISFILE.C: Return in ERROR_LEVEL the number of files present in the
  3.  *           directory given as argument (0 if empty)
  4.  *
  5.  *    Public Domain by Francois Bergeon (CIS: 73377,3170), September 1990
  6.  *
  7.  *    Compile with Turbo-C
  8.  */
  9. #include <stdio.h>
  10. #include <dos.h>
  11. #include <dir.h>
  12.  
  13. void main(argc, argv)
  14. int argc;
  15. char *argv[];
  16.    {
  17.    struct ffblk buf;
  18.    char dir[128];
  19.    int n = 0;
  20.  
  21.    if (argc != 2)
  22.       {
  23.       printf("Argument is a directory name\n");
  24.       exit(-1);
  25.       }
  26.    strcpy(dir, argv[1]);
  27.    strcat(dir, "\\*.*");
  28.    if (findfirst(dir, &buf, 0) == 0)
  29.       do
  30.         ++n;
  31.       while (findnext(&buf) >= 0);
  32.    exit(n);
  33.    }
  34.